package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SafetyPublicityInfo;
import com.ruoyi.system.service.ISafetyPublicityInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 安全宣传信息Controller
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/publicityinfo")
public class SafetyPublicityInfoController extends BaseController
{
    @Autowired
    private ISafetyPublicityInfoService safetyPublicityInfoService;

    /**
     * 查询安全宣传信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:publicityinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(SafetyPublicityInfo safetyPublicityInfo)
    {
        startPage();
        List<SafetyPublicityInfo> list = safetyPublicityInfoService.selectSafetyPublicityInfoList(safetyPublicityInfo);
        return getDataTable(list);
    }

    /**
     * 导出安全宣传信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:publicityinfo:export')")
    @Log(title = "安全宣传信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SafetyPublicityInfo safetyPublicityInfo)
    {
        List<SafetyPublicityInfo> list = safetyPublicityInfoService.selectSafetyPublicityInfoList(safetyPublicityInfo);
        ExcelUtil<SafetyPublicityInfo> util = new ExcelUtil<SafetyPublicityInfo>(SafetyPublicityInfo.class);
        return util.exportExcel(list, "publicityinfo");
    }

    /**
     * 获取安全宣传信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:publicityinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(safetyPublicityInfoService.selectSafetyPublicityInfoById(id));
    }

    /**
     * 新增安全宣传信息
     */
    @PreAuthorize("@ss.hasPermi('system:publicityinfo:add')")
    @Log(title = "安全宣传信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SafetyPublicityInfo safetyPublicityInfo)
    {
        return toAjax(safetyPublicityInfoService.insertSafetyPublicityInfo(safetyPublicityInfo));
    }

    /**
     * 修改安全宣传信息
     */
    @PreAuthorize("@ss.hasPermi('system:publicityinfo:edit')")
    @Log(title = "安全宣传信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SafetyPublicityInfo safetyPublicityInfo)
    {
        return toAjax(safetyPublicityInfoService.updateSafetyPublicityInfo(safetyPublicityInfo));
    }

    /**
     * 删除安全宣传信息
     */
    @PreAuthorize("@ss.hasPermi('system:publicityinfo:remove')")
    @Log(title = "安全宣传信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(safetyPublicityInfoService.deleteSafetyPublicityInfoByIds(ids));
    }
}
